package com.moter.one.wyydemo1.service;

import com.moter.one.wyydemo1.entity.UserInfo;
import com.moter.one.wyydemo1.mapper.UserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoService {
    //根据传送的对象插入userinfo对象
    @Autowired
    private UserInfoMapper userInfoMapper;
    public  int insertUserInfoMapper(UserInfo userInfo){
        int i = userInfoMapper.insertUserInfo(userInfo);//插入是否成功
        return i;
    }

    //根据传送的对象删除userinfo对象
    public int  deleteUserInfoMapper(UserInfo userInfo){
        int i = userInfoMapper.deleteUserInfo(userInfo);
        return i;
    }

    //后台管理查询所有用户
    public  List<UserInfo> searchAllUsers(){
        return userInfoMapper.selectUserInfo();
    }

    //后台管理 分页展示
    public List<UserInfo> searchAllByPage(Integer page, Integer limit) {
        return userInfoMapper.searchAllByPage(page, limit);
    }

    //多条件查询
    public List<UserInfo> searchBy_account_nickname_phone(String account,String nickname,String phone){
        return userInfoMapper.searchBy_account_nickname_phone(account,nickname,phone);
    }

    //根据id删除用户
    public Integer deleteByAccount(String account){
        return userInfoMapper.deleteByAccount(account);
    }

    public UserInfo getUserByAccount(String account){
        return userInfoMapper.getUserByAccount(account);
    }
}
